/*
 *    Copyright (c) 2020-2025, sunlei All rights reserved.
 *    jquery ajax 通用函数
 */

function getImgUpLoadUrl(){
  return "https://servicepdev.kpcb.org.cn/abkj-api-auth-provider/login/putfile";
}

function slAjax(url,method,query,SuccessFunc,FailedFunc,ischeckid) {
    $.ajax({
        // "url": "https://serviceprod.kpcb.org.cn"+url,
        "url": "https://serviceprod.kpcb.org.cn"+url,
        "headers":{
          "Authorization":localStorage.getItem("token")
        },
        "method": method,
        "cache": false,
        "async": false,
        "crossDomain":true,
        "contentType":"application/json",
        "dataType":"json",
        "data":JSON.stringify(query),
        "success":function (data) {
           //var data = JSON.parse(data);
           if(data.code != 0){
               if(data.code == -403){
                  layer.confirm( data.message,
                      function (index) {
	                      window.top.location.href = 'login.html'
                   })
               }
               // alert(data.message)
               if (ischeckid=='0'&&data.message=='用户名或者密码错误'){
                return layer.msg('请登录电子学会比赛平台进行注册，并确认参赛。', {icon: 5})
               }
               else {
                return layer.msg(data.message, {icon: 5})
               }

               FailedFunc(data.code,data.message);
               return;
           }
            SuccessFunc(data.data);
        },
        "error":function(e){
            if(e.status == 401){
              var varErrorObj = JSON.parse(e.responseText)
              if(varErrorObj.code == -403){
                  layer.confirm( varErrorObj.message,
                      function (index) {
	                      window.top.location.href = 'login.html'
                   })
               }
            }else {
              FailedFunc(e.status,e.responseText)
            }

            //console.log(e.status+":"+e.responseText);
        }
      }
    )
}
